package com.sichem.domain.activity.service.trial.thread;

import com.sichem.domain.activity.adapter.repository.IActivityRepository;
import com.sichem.domain.activity.model.valobj.GroupBuyActivityDiscountVO;
import com.sichem.domain.activity.model.valobj.SCSkuActivityVO;

import java.util.concurrent.Callable;

/**
 * @Author xiangshizhen
 * @Date 2025/2/10
 */
public class QueryGroupBuyActivityDiscountVOThreadTask implements Callable<GroupBuyActivityDiscountVO> {

    private final String source;

    private final String channel;

    private final IActivityRepository activityRepository;

    private final String goodsId;

    public QueryGroupBuyActivityDiscountVOThreadTask(String source, String channel, IActivityRepository activityRepository, String goodsId) {
        this.source = source;
        this.channel = channel;
        this.activityRepository = activityRepository;
        this.goodsId = goodsId;
    }


    @Override
    public GroupBuyActivityDiscountVO call() throws Exception {
        SCSkuActivityVO scSkuActivityVO =  activityRepository.querySCSkuActivityBySCGoodsId(source, channel, goodsId);
        if (null == scSkuActivityVO) return null;

        return activityRepository.queryGroupBuyActivityDiscountVO(scSkuActivityVO.getActivityId());
    }

}
